Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

native 16bit int and large floats fix #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

StuartGorman
Copy link

On a processor where an int is 16 bit, the max float value will be capped to 32767 due to type conversions. The PRINTF_MAX_FLOAT define is meant to prevent this limitation being exposed but it was written with 32 bit ints in mind (PRINTF_MAX_FLOAT default of 1e9 is less than int32 max of 2,147,483,647). Explicitly setting the conversion type to int32_t fixes this. Added a note in readme against the define as a gotcha.

On a processor where an int is 16 bit, the max float value will be capped to 32767 due to type conversions. The PRINTF_MAX_FLOAT define is meant to prevent the limitation being exposed but it was written with 32 bit ints in mind. Explicitly setting the conversion type to int32_t fixes this. Added a note in readme against the define as a gotcha
@codecov-io
Copy link

Codecov Report

Merging #77 into master will not change coverage by %.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #77   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines          359       359           
=========================================
  Hits           359       359           
Impacted Files Coverage Δ
printf.c 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d3b9846...145ded0. Read the comment docs.

KarlK90 pushed a commit to qmk/printf that referenced this pull request Jul 7, 2022
KarlK90 pushed a commit to qmk/printf that referenced this pull request Jul 7, 2022
…uld only be preceded by other preprocessor directives or comments.
KarlK90 pushed a commit to qmk/printf that referenced this pull request Jul 7, 2022
…ll only be used with either a preceding `&`, or with a parenthesized parameter list, which may be empty.
KarlK90 pushed a commit to qmk/printf that referenced this pull request Jul 7, 2022
…ot be used. ... so, when printf is used in C++, we use the C++-version of the C library headers.
KarlK90 pushed a commit to qmk/printf that referenced this pull request Jul 7, 2022
…unction-like macro each instance of a parameter shall be enclosed in parentheses unless it is used as the operand of `#` or `##`.
KarlK90 pushed a commit to qmk/printf that referenced this pull request Jul 7, 2022
KarlK90 pushed a commit to qmk/printf that referenced this pull request Jul 7, 2022
* More use of typedef's over raw primitive C types. Specifically, using `printf_size_t` in many relevant places
* Regards mpaland#77
* Removed redundant parentheses
* Comment tweaks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants